package com.common.app.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import com.common.app.R;
import com.common.base.widget.tab.XTabLayout;

public class AnalyzeXTabLayout extends XTabLayout {

    public AnalyzeXTabLayout(Context context) {
        super(context);
    }

    public AnalyzeXTabLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void setTabStyle(boolean isSelect, int i, View tabView, int position, int mTabCount) {
        if (tabView != null) {
            View tabSplit = tabView.findViewById(R.id.splitView);
            if (isSelect) {
                tabSplit.setVisibility(View.GONE);
            } else {
                if (position != 0 && i == position - 1) {
                    tabSplit.setVisibility(View.GONE);
                } else {
                    tabSplit.setVisibility(View.VISIBLE);
                }
            }
            if (i == mTabCount - 1)
                tabSplit.setVisibility(View.GONE);
        }
        super.setTabStyle(isSelect, i, tabView, position, mTabCount);
    }

    @Override
    public int setTabLayout() {
        return R.layout.analyze_layout_tab;
    }
}
